package xj.model.uml;

public enum Visibility {

  Default, Public, Protected, Private, Package;

  public String toDisplayString() {
    switch (this) {
    case Public:
      return "public";
    case Protected:
      return "protected";
    case Private:
      return "private";
    case Package:
      return "package";
    case Default:
    default:
      return "";
    }						
  }

  public char toChar() {
    switch (this) {
    case Public:
      return '+';
    case Protected:
      return '#';
    case Private:
      return '-';
    case Package:
      return '~';
    case Default:
    default:
      return ' ';
    }
  }

  public static Visibility toVisibility(String s) {
    if (s != null) { 
      s = s.trim().toLowerCase();
      if ("public".equals(s)) { 
	return Visibility.Public;
      } else if ("protected".equals(s)) { 
	return Visibility.Protected;
      } else if ("private".equals(s)) { 
	return Visibility.Private;
      } else if ("package".equals(s)) { 
	return Visibility.Package;
      }
    }
    return Visibility.Default;
  }

}
